import request from '@/utils/request'
import * as x3 from "@/utils/x3request"
const publicNmae="GESYCCE3"

// 查询一级办事处列表
export function listGescce(query) {
  // console.log(query)
  var objectKeys=""
  Object.keys(query).forEach(function(key) {
    console.log(key + ': ' + query[key]);
    if(query[key]!=null && !['pageNum','pageSize'].includes(key)){
      objectKeys+="<key>"+key+"</key>"
      objectKeys+="<value>"
      if(['DES','YSQSJ','YBZ'].includes(key)){
        objectKeys+="*"+query[key]+"*"
      }else{
        objectKeys+=""+query[key]+""
      }
      objectKeys+="</value>"
    }
  });

  return x3.query(publicNmae,objectKeys,query.pageSize)
  return request({
    url: '/x3base/gescce/list',
    method: 'get',
    params: query
  })
}

// 查询一级办事处详细
export function getGescce(cce) {
  return x3.read(publicNmae,"<key>DIE</key>" +
    "<value>AX3</value>" +
    "<key>CCE</key>" +
    "<value>"+cce+"</value>")
  return request({
    url: '/x3base/gescce/' + cce,
    method: 'get'
  })
}

// 新增一级办事处
export function addGescce(data) {
  return x3.save(publicNmae,{"HEAD":data})
  return request({
    url: '/x3base/gescce',
    method: 'post',
    data: data
  })
}

// 修改一级办事处
export function updateGescce(data) {
  return x3.modify(publicNmae,"<key>DIE</key>" +
    "<value>AX3</value>" +
    "<key>CCE</key>" +
    "<value>"+data.CCE+"</value>",{"HEAD":data})
  return request({
    url: '/x3base/gescce',
    method: 'put',
    data: data
  })
}

// 删除一级办事处
export function delGescce(cce) {
  return x3.del(publicNmae,"<key>DIE</key>" +
    "<value>AX3</value>" +
    "<key>CCE</key>" +
    "<value>"+cce+"</value>")
  return request({
    url: '/x3base/gescce/' + cce,
    method: 'delete'
  })
}

// 按钮操作一级办事处
export function actionGescce(data,code) {
  return x3.actionObject(publicNmae,{"HEAD":data},code)
  return request({
    url: '/x3base/gescce/' + cce,
    method: 'delete'
  })
}
